import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class User extends StatelessWidget {
  final List imgs = [
    "http://hbimg.b0.upaiyun.com/a3e592c653ea46adfe1809e35cd7bc58508a6cb94307-aaO54C_fw658",
    "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2259614868,961155351&fm=26&gp=0.jpg"
  ];
  //final List menu = [{"name":"个人信息"},{"name":"收货地址"},{"name":"我的消息"},{"name":"系统设置"}];
  List menu = ["个人信息","收货地址","我的消息","系统设置"];

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context,width: 750,height: 1334);
    return Scaffold(
      appBar: AppBar(
        title: Text("我的"),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            _userInfo(),
            _userMenu()
          ],
        ),
      ),
    );
  }

  Widget _userInfo(){
    return Container(
      height: ScreenUtil().setWidth(320),
      padding: EdgeInsets.only(left: ScreenUtil().setWidth(30),right: ScreenUtil().setWidth(30)),
      color: Colors.white,
      child: Row(
        children: <Widget>[
          Container(
            width: ScreenUtil().setWidth(160),
            height: ScreenUtil().setWidth(160),
            margin: EdgeInsets.only(right: ScreenUtil().setWidth(30)),
            child: CircleAvatar(
              // child: Image.network(imgs[0]),
              backgroundImage: NetworkImage(imgs[0]),
            ),
          ),
          Expanded(child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(bottom:ScreenUtil().setWidth(20)),
                child: Text("昵称"),
              ),
              Text("15716022393")
            ],
          )),
          Icon(Icons.arrow_right)
        ],
      ),
    );
  }
  Widget _userMenu() {
    return Container(
      padding: EdgeInsets.only(left: ScreenUtil().setWidth(30),right: ScreenUtil().setWidth(30)),
      color: Colors.white,
      margin: EdgeInsets.only(top:ScreenUtil().setWidth(30)),
      child: Column(
        children: <Widget>[
          _menuItem(0),
          _menuItem(1),
          _menuItem(2),
          _menuItem(3)
        ],
      ),
    );
  }

  Widget _menuItem(int index) {
    return Container(
      height: ScreenUtil().setWidth(110),
      child: Row(
        children: <Widget>[
          Icon(Icons.library_music),
          Expanded(child: Text(index.toString())),
          Icon(Icons.arrow_right)
        ],
      ),
    );
  }

}